#nullable enable

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using PHMEE.DTOS.Diagnosis;
using PHMEE.IServices.Diagnosis;
using Volo.Abp.Application.Dtos;

namespace PHMEE.Controllers.Diagnosis;

[Route("api/diagnosis/alarm-record")]
public class AlarmRecordController : PHMEEController, IAlarmRecordAppService
{
    private readonly IAlarmRecordAppService _alarmRecordAppService;

    public AlarmRecordController(IAlarmRecordAppService alarmRecordAppService)
    {
        _alarmRecordAppService = alarmRecordAppService;
    }

    [Route("GetList")]
    [HttpGet]
    public Task<PagedResultDto<AlarmRecordBriefDto>> GetListAsync(Guid vesselId, AlarmRecordListFilterDto input)
    {
        return _alarmRecordAppService.GetListAsync(vesselId, input);
    }

    [Route("GetDetail")]
    [HttpGet]
    public Task<AlarmRecordDetailDto> GetDetailAsync(Guid id)
    {
        return _alarmRecordAppService.GetDetailAsync(id);
    }

    [Route("GetAckStatus")]
    [HttpGet]
    public Task<AlarmRecordAckStatusDto> GetAckStatusAsync(Guid id)
    {
        return _alarmRecordAppService.GetAckStatusAsync(id);
    }

    [Route("SetAckStatus")]
    [HttpPost]
    public Task SetAckStatusAsync(AlarmRecordAckStatusSetDto input)
    {
        return _alarmRecordAppService.SetAckStatusAsync(input);
    }

    /// <summary>
    /// 获取报警诊断报告
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [Route("GetAlarmDiagReport")]
    [HttpGet]
    public Task<AlarmDiagReportDto> GetAlarmDiagReportAsync(Guid id)
    {
        return _alarmRecordAppService.GetAlarmDiagReportAsync(id);
    }

    /// <summary>
    /// 获取指定机组的最新未被确认的报警记录集合（5 条）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="unitId"></param>
    /// <returns></returns>
    [Route("GetLatestUnAckedAlarmRecords")]
    [HttpGet]
    public Task<IEnumerable<AlarmRecordRealtimeDto>> GetLatestUnAckedAlarmRecordsAsync(Guid vesselId, Guid unitId)
    {
        return _alarmRecordAppService.GetLatestUnAckedAlarmRecordsAsync(vesselId, unitId);
    }

    /// <summary>
    /// 获取船舶所有机组的振动未被 Ack 的报警 + Ams 开关量报警的数量，并按机组分组返回
    /// </summary>
    /// <param name="vesselId"></param>
    /// <returns></returns>
    [Route("GetRealTimeUnitsAlarmCount")]
    [HttpGet]
    public Task<List<RealTimeUnitsAlarmCountDto>> GetRealTimeUnitsAlarmCountAsync(Guid vesselId)
    {
        return _alarmRecordAppService.GetRealTimeUnitsAlarmCountAsync(vesselId);
    }
}